package com.company.demo.observer_pattern;

import java.util.ArrayList;
import java.util.List;

public class ConcreteSubject implements Subject {
    List<Observer> observerList = new ArrayList<Observer>();

    @Override
    public void addObserver(Observer observer) {
        observerList.add(observer);
    }

    @Override
    public void delObserver(Observer observer) {
        observerList.remove(observer);
    }

    @Override
    public void notifyObserver(String msg) {
        for (Observer observer :
                observerList) {
            observer.update(msg);
        }
    }
}
